import { createPinia } from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";
import { lStorage } from "@/utils/storage";

const pinia = createPinia();
// 将插件添加到 pinia 实例上，全局配置持久化的storage
pinia.use(
    createPersistedState({
        storage: {
            getItem: (key) => {
                return lStorage.get(key);
            },
            setItem: (key, value) => {
                lStorage.set(key, value);
            },
        },
    })
);

export default pinia;
